﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyClassLibrary
{
    public static class ClsRecord
    {

        public static int StaffID=1;
        public static void Record(object sender, string formName)
        {
            string ButtonText;
            if(sender is Button)
            { ButtonText=((Button)sender).Text;}
            else
            { ButtonText = ((ToolStripItem)sender).Text; }
            MyDB.MedicareDataClassesDataContext DB = new MyDB.MedicareDataClassesDataContext();
            int formID = DB.Forms.Where(n => n.表單英文名稱 == formName).First().表單ID;
            MyDB.UseRecord ur = new MyDB.UseRecord { 使用時間 = DateTime.Now, 使用功能 = ButtonText, 病患ID = null, 醫療人員ID = StaffID, 表單ID = formID };
            DB.UseRecord.InsertOnSubmit(ur);
            DB.SubmitChanges();
        }

        public static void Record(object sender, string formName, int PatientID)
        {
            string ButtonText;
            if (sender is Button)
            { ButtonText = ((Button)sender).Text; }
            else
            { ButtonText = ((ToolStripItem)sender).Text; }
            MyDB.MedicareDataClassesDataContext DB = new MyDB.MedicareDataClassesDataContext();
            int formID = DB.Forms.Where(n => n.表單英文名稱 == formName).First().表單ID;
            MyDB.UseRecord ur = new MyDB.UseRecord { 使用時間 = DateTime.Now, 使用功能 = ButtonText, 病患ID = PatientID, 醫療人員ID = StaffID, 表單ID = formID };
            DB.UseRecord.InsertOnSubmit(ur);
            DB.SubmitChanges();
        }
    }
}
